<html>
<head>
<link href="../../../Objects/sofa_white.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div id="contenu">
		
		<center><h3>Creation of a Scene (5/9)</h3></center>
		<center><img src="4_FullObject.png" width="300" name="FullObject" align="middle"></center>
		
		<br><div id="orangeText">Description</div>
		<p>In this step we will use a visual model to represent our deformable object. Nevertheless, you must keep in mind that it will only be a visual representation. The computational work will be done on the particles you are not used to seeing.</p>

		<div id="orangeText">Key points</div>
        
        <p><div id="tutorialAction"> Add a <strong>GNode</strong> to the <strong>Object</strong> node. Rename this node "VisualNode".</div></p>
        
        <p>We added a Node that will contain our Visual Model. Next, we move our Visual Model from the <strong>root</strong> level to the <strong>VisualNode</strong>.</p>
         
        <div id="tutorialAction"><p>Select the <strong>OglModel</strong> in the Modeler's scene graph. Press the <strong>Copy</strong> button, found in the Modeler toolbar, 4th from the left. Select the <strong>VisualNode</strong>, and press the <strong>Paste</strong> button, found to the right of the <strong>Copy</strong> button. Right click the original <strong>OglModel</strong>, and select <strong>Delete</strong>.</p></div>      
                
                
        <p>Now to make the link between the deformation of the simulated particles and a given visual model, we need a mapping. As we only need to update the positions of the visual model at each time step, we will use a Visual Mapping: <b>BarycentricMapping</b>.</p>
         
   		<p>Here we really need to pay attention to the template used for this component.</p>
        
        <p><div id="tutorialAction">Open the <strong>OglModel</strong> properties and go to the <strong>Infos</strong> tab. </div></p>
        
        <p>Under <strong>instance</strong>, you can see that the <strong>Template</strong> is <strong>ExtVec3f</strong>. This means we need our <strong>BarycentricMapping</strong> to map from <strong>Vec3d</strong> (the template used by the <strong>MechanicalObject</strong>) to <strong>ExtVec3f</strong>.</p>
        
        <div id="tutorialAction"><p>Find the <strong>BarycentricMapping</strong> component using the <strong>Filter</strong>. Be sure that the template information to the right reads <strong>Vec3d, ExtVec3f</strong>. If it doesn't, choose that combination from the drop down menu. Add this component to the <strong>VisualModel</strong> node. </p>
        <p>Edit the properties of the <strong>BarycentricMapping</strong>, and open the <strong>Property 2/2</strong> tab. Change <strong>Input object to map</strong> from <strong>@</strong> to "@..".</p></div>
        
        <p>This refers to the <strong>MechanicalObject</strong> placed in the node above (<strong>Object</strong> node)</p>
        
        <p><div id="tutorialAction">Change <strong>Output object to map</strong> to "@Objective".</div></p>
        
        <p>This refers to the <strong>OglModel</strong> that we named <strong>Objective</strong> earlier</p>
                     
		<div id="orangeText">Result</div>
		
        <p><div id="tutorialAction">Run in SOFA and animate</div></p>
        
        <p>Now not only are the particles of the grid deformed, but this deformation is propagated to the visual model, which remains embedded inside the grid at all times.</p>

		<div id="orangeText">Related</div>
        <p>As you may have noticed, the visual model is fully independent from the simulated model: We used the same model to create the deformable grid as we did to create the visual model, but nothing stops you from using a different model. Change the visual model or the model used in the <b>SparseGridTopology</b> and see the effect.</p>
         <p>To understand how the barycentric mapping works, display the Visual Mappings debug information in the SOFA main application. You will see how each point of the visual model depends on some of the points of the mechanical model.</p>

                <br><center><h3><a href="3_FullObject.scn">Previous</a> ____________  <a href="5_FullObject.scn">Next</a></center></h3>
	</div>
</body>
</html>
